<!DOCTYPE html>
<html lang="zh-CN" style="height:100%">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Tqmall Api文档</title>
    <link href="/Public/frontapp/media/css/api-bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <link href="/Public/frontapp/media/css/api-style.css" rel="stylesheet" type="text/css"/>
    <!--[if lt IE 9]>
    <script src="/Public/frontapp/media/js/html5shiv.min.js"></script>
    <script src="/Public/frontapp/media/js/respond.min.js"></script>
    <![endif]-->
</head>
<body style="height:100%">
<div class="container-fluid" style="background:white;height:100%;">
    <div class="row" style="height:100%;">
        <!--左侧导航start-->
        <div id="navbar" class="col-md-3"
             style="position:relative;background:#f5f5f5;padding:10px;height:100%;border-right:#ddd 1px solid;overflow-y:auto;">
            <div style="height:50px;font-size:30px;line-height:50px;">
                <a class="home" style="color:#000000;text-shadow:1px 0px 1px #666;text-decoration: none" href="">
                    <span class="glyphicon glyphicon-random" aria-hidden="true" style="width:40px;"></span>&nbsp;
                    <span style="position: relative;top:-3px;">Tqmall Api文档<span
                            style="font-size:12px;position:relative;top:-13px;">&nbsp;</span></span>
                </a>
            </div>
            <include file="Layouts:api_menu"/>
        </div>
        <!--左侧导航end-->
        <div id="mainwindow" class="col-md-9"
             style="height:100%;background:white;margin:0px;overflow-y:auto;padding:0px;">
            <!--顶部导航start-->
            <div class="textshadow"
                 style="font-size:16px;widht:100%;height:60px;line-height:60px;padding:0 16px 0 16px;;border-bottom:#ddd 1px solid">
            <span>
            <?php
            $length = sizeof($navigator);
            $count = 1;
            foreach ($navigator as $item) {
                if ($length != $count) {
                ?>
                <a href="{$item['url']}">{$item['name']}</a>&nbsp;->&nbsp;
                <?php
                } else {
                ?>
                <a href="{$item['url']}">{$item['name']}</a>
                <?php
                }
                $count++;
            }
            ?>
            </span>
        <span id="topbutton" style="float:right">
            <?php
                echo '欢迎您：' . $_SESSION['dept_name'] . '-' . $_SESSION['username'];;
            ?>
        </span>
            </div>
            <!--顶部导航end-->
            <!--主窗口start-->
            <div style="padding:16px;">
                <!--接口详情列表与接口管理start-->

                <!--接口详细列表start-->
                <?php if(count($list)){ ?>
                <?php
                foreach($list as $v){
                ?>
                <div class="info_api" style="border:1px solid #ddd;margin-bottom:80px;"
                     id="info_api_<?php echo md5($v['id'])?>">
                    <div style="background:#f5f5f5;padding:20px;position:relative">
                        <div class="textshadow" style="position: absolute;right:0;top:4px;right:8px;">
                            最后修改者: <?php echo $v['realname']?> &nbsp;<?php echo date('Y-m-d H:i:s',$v['lasttime'])?>
                            &nbsp;
                            <button class="btn btn-danger btn-xs ">删除
                            </button>
                            &nbsp;
                            <button class="btn btn-info btn-xs edit">
                                编辑
                            </button>
                            <input type="hidden" class="id" value="<?php echo $v['id'] ?>"/>
                            <input type="hidden" class="cate_id" value="<?php echo $_GET['cate_id'] ?>"/>
                        </div>
                        <h4 class="textshadow"><?php echo $v['name']?></h4>

                        <p>
                            <b>编号&nbsp;&nbsp;:&nbsp;&nbsp;<span style="color:red"><?php echo $v['num']?></span></b>
                        </p>

                        <div>
                            <?php
                        $color = 'green';
                        if($v['type']=='POST'){
                            $color = 'red';
                        }
                    ?>
                            <kbd style="color:<?php echo $color ?>"><?php echo $v['type']?></kbd> -
                            <kbd><?php echo $v['url']?></kbd>
                        </div>
                    </div>
                    <?php if(!empty($v['des'])){ ?>
                    <div class="info">
                        <?php echo $v['des']?>
                    </div>
                    <?php } ?>
                    <div style="background:#ffffff;padding:20px;">
                        <h5 class="textshadow">请求参数</h5>
                        <?php
                        if (!empty($v['raw_param'])) {
                        ?>
                        <pre style="background:honeydew"><?php echo htmlspecialchars($v['raw_param']) ?></pre>
                        <?php
                        }

                        if (!empty($v['parameter'])) {
                        ?>
                        <table class="table">
                            <thead>
                            <tr>
                                <th class="col-md-3">参数名</th>
                                <th class="col-md-2">必传</th>
                                <th class="col-md-2">缺省值</th>
                                <th class="col-md-5">描述</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php
                        $parameter = unserialize($v['parameter']);
                        $pnum = count($parameter['name']);
                    ?>
                            <?php for( $i=0; $i<$pnum; $i++ ) {?>
                            <tr>
                                <td><?php echo $parameter['name'][$i]?></td>
                                <td><?php if($parameter['type'][$i]=='Y'){echo '<span style="color:red">Y<span>';}else{echo '<span
                                        style="color:green">N<span>';}?></td>
                                <td><?php echo $parameter['default'][$i]?></td>
                                <td><?php echo $parameter['des'][$i]?></td>
                            </tr>
                            <?php } ?>

                            </tbody>
                        </table>
                        <?php
                        }
                        ?>
                    </div>
                    <?php if(!empty($v['re'])){ ?>
                    <div style="background:#ffffff;padding:20px;">
                        <h5 class="textshadow">返回值</h5>
                        <pre><?php echo htmlspecialchars($v['re']) ?></pre>
                    </div>
                    <?php } ?>
                    <?php if(!empty($v['memo'])){ ?>
                    <div style="background:#ffffff;padding:20px;">
                        <h5 class="textshadow">备注</h5>
                        <pre style="background:honeydew"><?php echo $v['memo']?></pre>
                    </div>
                    <?php } ?>
                </div>
                <!--接口详细列表end-->
                <?php } ?>
                <?php } else{ ?>
                <div style="font-size:16px;">
                    <span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> 此分类下还没有任何接口
                </div>
                <?php }?>
                <!--接口详情列表与接口管理end-->
            </div>
            <!--主窗口end-->
        </div>
    </div>
</div>
<script src="/Public/frontapp/media/js/jquery-1.10.1.min.js"></script>
<script src="/Public/frontapp/media/js/jquery.cookie.min.js"></script>
<script src="/Public/frontapp/media/js/bootstrap.min.js"></script>
<script>
    //删除某个接口
    function deleteApi(apiId, divId) {
        if (confirm('是否确认删除此接口?')) {
            $.post($url, {id: apiId}, function (data) {
                if (data == '1') {
                    $('#api_' + divId).remove();//删除左侧菜单
                    $('#info_api_' + divId).remove();//删除接口详情
                }
            })
        }
    }

    $(function () {
        $('.edit').click(function () {
            var id = $(this).siblings('.id').val();
            var cate_id = $(this).siblings('.cate_id').val();
            editApi('/home/api/edit_page?cate_id=' + cate_id + '&id=' + id);
        });
    });
    //编辑某个接口
    function editApi(gourl) {
        window.location.href = gourl;
    }

    //检测滚动条,显示返回顶部按钮
    document.getElementById('mainwindow').onscroll = function () {
        if (document.getElementById('mainwindow').scrollTop > 100) {
            document.getElementById('gotop').style.display = 'block';
        } else {
            document.getElementById('gotop').style.display = 'none';
        }
    };
</script>
</body>
</html>